package com.jv.webmvc.controller;

import com.jv.webmvc.entity.User;
import com.jv.webmvc.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

@RestController
@Scope("session")
@RequestMapping("/emp")
public class EmpController {
	public EmpController(){
		System.out.println("............EmpController......Init..........");
	}
	private User user ;

	@Autowired
	private EmpService empService;

	/**
	 * @RequestParam 由RequestParamMethodArgumentResolver负责解析，完成参数绑定
	 * @PathVariable 由PathVariableMethodArgumentResolver负责解析，完成参数绑定
	 * @RequestBody  由RequestBodyMethodArgumentResolver负责解析，完成参数绑定
	 *
	 * @param userName
	 * @param age
	 * @return
	 */
	@RequestMapping(value = "/all/{age}",method = RequestMethod.GET)
	public User queryAllUser(@RequestParam("name") String userName, @PathVariable("age") Integer age){
		user = new User(userName,age);
		System.out.println(user);
		return user;
	}

	@RequestMapping("/queryByName")
	public User queryUserByName(@RequestParam("name") String userName){
		user = new User(userName,33);
		System.out.println(user);
		return user;
	}
}
